/**
 * Copyright (C) 2017 - 2020 https://github.com/joewee
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bifrost.game.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 奖品库
 *
 * @author joewee
 * @version 1.0.0
 * @Date 2018/5/8 13:38
 */
@Entity
@Table(name = "LOTTERY_AWARD")
public class LotteryAward implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;
    /**
     * 奖品名称
     */
    @Column(name = "NAME", length = 64)
    private String name;
    /**
     * 奖品描述
     */
    @Column(name = "DESCRIPTION")
    private String description;
    /**
     * 奖品图片链接
     */
    @Column(name = "IMG_URL")
    private String imgUrl;
    /**
     * 奖品价格
     */
    @Column(name = "PRICE")
    private BigDecimal price = BigDecimal.ZERO;
    /**
     * 奖品类型
     */
    @Column(name = "AWARD_TYPE", length = 32, nullable = false)
    @Enumerated(value = EnumType.STRING)
    private AwardType awardType = AwardType.COUPON;
    /**
     * 数量
     */
    @Column(name = "QUANTITY", nullable = false)
    private Integer quantity = 0;
    /**
     * 积分值当awardType = AwardType.VIRTUAL时有值
     */
    @Column(name = "BONUS_POINTS")
    private Integer bonusPoints = 0;
    /**
     * 优惠券id值当awardType = AwardType.COUPON时有值
     */
    @Column(name = "COUPON_ID")
    private Long couponId;
    /**
     * 门店
     */
    @Column(name = "MERCHANT_ID")
    private Long merchantId;
    /**
     * 排序号
     */
    @Column(name = "SORT_ORDER")
    private Integer sortOrder = 1;
    @OneToMany(mappedBy = "lotteryAward",fetch = FetchType.LAZY)
    @JsonIgnore
    private List<LotteryGameAward> lotteryGameAwards;
    @OneToMany(mappedBy = "lotteryAward",fetch = FetchType.LAZY)
    @JsonIgnore
    private List<LotteryGameWinner> lotteryGameWinners;

    public enum AwardType {
        /**
         * 卡券
         */
        COUPON,
        /**
         * 实物
         */
        PHYSICAL,
        /**
         * 虚拟商品
         */
        VIRTUAL;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public AwardType getAwardType() {
        return awardType;
    }

    public void setAwardType(AwardType awardType) {
        this.awardType = awardType;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Integer getBonusPoints() {
        return bonusPoints;
    }

    public void setBonusPoints(Integer bonusPoints) {
        this.bonusPoints = bonusPoints;
    }

    public Long getCouponId() {
        return couponId;
    }

    public void setCouponId(Long couponId) {
        this.couponId = couponId;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }

    public List<LotteryGameAward> getLotteryGameAwards() {
        return lotteryGameAwards;
    }

    public void setLotteryGameAwards(List<LotteryGameAward> lotteryGameAwards) {
        this.lotteryGameAwards = lotteryGameAwards;
    }

    public List<LotteryGameWinner> getLotteryGameWinners() {
        return lotteryGameWinners;
    }

    public void setLotteryGameWinners(List<LotteryGameWinner> lotteryGameWinners) {
        this.lotteryGameWinners = lotteryGameWinners;
    }
}
